package com.leef.createPay.controller;

import com.leef.createPay.result.CommonCode;
import com.leef.createPay.result.response.PayResult;

import com.leef.createPay.service.CreatePayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CreatePayController {
    @Autowired
    CreatePayService createPayService;

    @Value("${leef.createPay}")
    String payId;

    @GetMapping("/create/order/{payCode}/{payId}")
    public PayResult createPay(@PathVariable("payCode")String payCode, @PathVariable("payId")String checkId){
        if(!checkId.equals(payId)){
            return new PayResult(CommonCode.INVALID_PARAM,null);
        }

        return createPayService.createPay(payCode);
    }
}
